package com.neusoft.elmboot.mapper;

import com.neusoft.elmboot.po.VirtualWallet;

import java.math.BigDecimal;

import org.apache.ibatis.annotations.*;

@Mapper
public interface WalletMapper {
	
	@Select("select * from wallet where userId=#{userId}")
   public VirtualWallet getWallet(String userId);
	
	/*@Update("update wallet set balance=balance-#{amount} where userId=#{userId}")
	public void debit(String userId, BigDecimal amount);
	
	@Update("update wallet set balance=balance+#{amount} where userId=#{userId}")
	public void credit(String userId, BigDecimal amount);*/
	
	@Update("update wallet set balance=#{amount} where userId=#{userId}")
	public void updateBalance(String userId, BigDecimal amount);
	
	@Insert("insert into wallettransaction(transactionId,transactionTime,amount,transactionType,inId,outId) values(#{transactionId},#{transactionTime},#{amount},#{transactionType},#{inId},#{outId})")
    public void saveTransaction(String transactionId,String transactionTime,BigDecimal amount,int transactionType,String inId,String outId);
	
	@Update("update wallet set balance=#{balance} where userId=#{userId}")
    public void updateWallet(VirtualWallet wallet);
    
	@Insert("insert into wallet(userId,createTime,balance) values(#{userId},#{createTime},#{balance})")
    public void createWallet(String userId,String createTime,BigDecimal balance);
	
	
}
